package com.wgy.day15.String字符串类;

import java.util.Scanner;

/**
 * Created by pc on 2020/11/10 22:32
 * Description: LearningJava
 */
public class Demo09StringPractise {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);//定义一个键盘输入的对象
        System.out.println("请输入一个字符串");
        String str = sc.next();             //获取键盘输入的字符串
        int countUpper = 0;                 //定义字符类型的技术名称
        int countLower = 0;
        int countNumber = 0;
        int countOther = 0;
        char[] chars = str.toCharArray();//将字符串转换成字符数组

        for (int i = 0; i < chars.length; i++) {
            char ch = chars[i];
            if ('A' <= ch && ch <= 'Z') {
                countUpper++;

            } else if ('a' <= ch && ch <= 'z') {
                countLower++;

            } else if ('0' <= ch && ch <= '9') {
                countNumber++;

            } else {
                countOther++;
            }

        }
        System.out.println("大写字符有" + countUpper + "个");
        System.out.println("小写字符有" + countLower + "个");
        System.out.println("数字字符有" + countNumber + "个");
        System.out.println("其他字符有" + countOther + "个");


    }
}
